/* 
 * File:   systask.h
 * Author: apleilx
 */

#ifndef PARTAB_H_H_
#define	PARTAB_H_H_

#ifdef   _PARTAB_MODULE_
#define  PAR_EXT
#else
#define  PAR_EXT  extern
#endif

#include "stdint.h"
#include "appconfig.h"
#include "mytype.h"
#include "parameter.h"

#ifdef	__cplusplus
extern "C" {
#endif

typedef struct
{
    const char  *en;
    const char  *ch;
} par_bit_info_type;
    
typedef const struct {
    uint16_t attr;
    int16_t min;
    int16_t max;
    int16_t init;
    const char  *en;
    const char  *ch;
    const par_bit_info_type * bit_code;
} par_attr_type;
    
typedef union {
    uint16_t uVal;
    int16_t  iVal;
    uint8_t  byte[2];
} par_tab_Type; 

 
    
void eep_par_save(uint16_t addr, uint16_t dat);
uint16_t eep_par_read(uint16_t addr);

void eep_sys_par_init(void);
void eep_sys_par_read(void);

void eep_read(uint16_t addr, uint16_t Len, void *pdat);

void eep_prog_write_all(void);
void eep_prog_read_all(void);

uint16_t par_attr_get(uint16_t par_num);
int32_t par_min_get(uint16_t par_num);
int32_t par_max_get(uint16_t par_num);
int32_t par_val_get(uint16_t par_num);
int32_t par_val_set(uint16_t par_num, int32_t par_val);


#ifndef PAR_TAB_SIZE
#define PAR_VERSIONID_POS                         0UL
#include "parindex.h"
#endif

#ifndef _PARTAB_MODULE_
uint8_t par_check(uint16_t par_num, int32_t par_val);
int32_t par_correct(uint16_t par_num, int32_t par_val);
#endif

extern par_attr_type par_attr_tab[];

PAR_EXT par_tab_Type par_tab[PAR_TAB_SIZE + 32];

#include "systask.h"

#ifdef	__cplusplus
}
#endif

#undef PAR_EXT

#endif	/* PARTAB_H_H_ */

